#include<iostream>
#include<mutex>
#include<condition_variable>
#include<thread>
using namespace std;

int main()
{
	mutex mux;
	condition_variable cv;
	int n = 100;
	int x=1;
	thread t1([&, n](){
		while (x < n)
		{
			
			unique_lock<mutex> st(mux);
				if (x % 2 == 0)
				cv.wait(st);
			
			cout << "pthread t1:" << x++ << endl;
			
			cv.notify_one();

		}
		
		
		
		});
	thread t2([&, n]() {
		while (x < n)
		{
			unique_lock<mutex> st(mux);
			if (x % 2!=0)
				cv.wait(st);
			
			cout << "pthread t2:" << x++ << endl;
			cv.notify_one();


		}



		});


	t1.join();
	t2.join();


	return 0;


}